<?php
$q = $_GET["q"];
$db = file_get_contents("data/exercise.json");
$db_array = json_decode($db, true);

$result_array = array();
foreach ($db_array as $key => $item) {
    # if find query is substring of set exercise
    if ((strpos($item, $q) !== false)) {
        $result_array[] = $item;
    }
}
echo json_encode($result_array);

?>
